<?php
namespace Home\Controller;
use Think\Controller;
class HomeBaseController extends Controller
{
    protected function _initialize(){
        $this->app_path   = '/Wpcfront';//项目名称，生产环境换成'/'
		$this->static_path   = '/Public';//静态资源目录
		$this->assign('static_path',$this->static_path);
		$this->assign('app_path',$this->app_path);
		$this->domain_name= 'http://batch.com';//域名
	}
	/**
	 * 日期间隔
	 * @param  $part 日期相差类型
	 * @param  $begin 开始时间
	 * @param  $end 截止时间
	 * @return number
	 */
	function DateDiff($part, $begin, $end)
	{
	    $diff = strtotime($end) - strtotime($begin);
	    switch($part)
	    {
	        case "y": $retval = bcdiv($diff, (60 * 60 * 24 * 365)); break;
	        case "m": $retval = bcdiv($diff, (60 * 60 * 24 * 30)); break;
	        case "w": $retval = bcdiv($diff, (60 * 60 * 24 * 7)); break;
	        case "d": $retval = bcdiv($diff, (60 * 60 * 24)); break;
	        case "h": $retval = bcdiv($diff, (60 * 60)); break;
	        case "n": $retval = bcdiv($diff, 60); break;
	        case "s": $retval = $diff; break;
	    }
	    return $retval;
	}
	
	
	/**
	 * 发送短信
	 */
	public function sendMobileMes(){
	    $MessEvent=D('Mess','Event');
	    $resp = $MessEvent->sendMobileMes(I('mobile',''));
	    $this->ajaxReturn($resp,'JSON');
	
	}
	/**
	 * 发送邮件
	 */
	public function sendEmailMes(){
	    $MessEvent=D('Mess','Event');
	    $resp = $MessEvent->sendEmailMes(I('email',''));
	    $this->ajaxReturn($resp,'JSON');
	}
}